package com.util.xls;

import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

/**
 * @auther carter
 * create time    2018-06-20
 */
class XlsTool {

    private HSSFWorkbook workbook;
    private HSSFSheet    sheet;
    private HSSFPatriarch patriarch;
    private String dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
    private String dateFormat = "yyyy-MM-dd";
    private HSSFFont font;

    public XlsTool(String title)
    {
        workbook = new HSSFWorkbook();
        sheet = workbook.createSheet(title);
        sheet.setDefaultColumnWidth(25);
        sheet.setDefaultRowHeight((short) 10);
        patriarch = sheet.createDrawingPatriarch();
        font=workbook.createFont();
        font.setColor(HSSFColor.BLACK.index);
    }


    public HSSFWorkbook getWorkbook() {
        return workbook;
    }

    public HSSFSheet getSheet() {
        return sheet;
    }

    public HSSFPatriarch getPatriarch() {
        return patriarch;
    }

    public String getDateTimeFormat() {
        return dateTimeFormat;
    }

    public void setDateTimeFormat(String dateTimeFormat) {
        this.dateTimeFormat = dateTimeFormat;
    }

    public String getDateFormat() {
        return dateFormat;
    }

    public void setDateFormat(String dateFormat) {
        this.dateFormat = dateFormat;
    }

    public HSSFFont getFont() {
        return font;
    }

    public void release()
    {
        workbook = null;
        sheet = null;
        patriarch=null;
        font = null;
        dateFormat=null;
        dateTimeFormat=null;
    }
}
